package com.cmschina.custom;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

/**
 * @author: li chao
 * @Desc:
 * @create: 2024-08-06 15:46
 **/
// 使用 Spring AOP 定义切面
@Aspect
@Component
public class MyAspect {

    @Before("@annotation(MyCustomAnnotation)")
    public void handleAnnotation(JoinPoint joinPoint) {

        Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
        MapperContextHolder.setCurrentMapperMethod(method);
        System.out.println("切面处理");
    }
}